define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'elevator/basic/info/index' + location.search,
                    add_url: 'elevator/basic/info/add',
                    edit_url: 'elevator/basic/info/edit',
                    del_url: 'elevator/basic/info/del',
                    multi_url: 'elevator/basic/info/multi',
                    import_url: 'elevator/basic/info/import',
                    table: 'elevator_basic_info',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'pinzhong', title: __('Pinzhong'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'mingcheng', title: __('Mingcheng'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'zhizao', title: __('Zhizao'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'factory_serial_number', title: __('Factory_serial_number'), operate: 'LIKE'},
                        {field: 'factory_date', title: __('Factory_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'product_model', title: __('Product_model'), operate: 'LIKE'},
                        {field: 'anzhuang', title: __('Anzhuang'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'anri', title: __('Anri'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'gaizao', title: __('Gaizao'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'gairi', title: __('Gairi'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'xiuli', title: __('Xiuli'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'xiuri', title: __('Xiuri'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'zhuce', title: __('Zhuce'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'guanli', title: __('Guanli'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'shiyong', title: __('Shiyong'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'didian', title: __('Didian'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'neibu', title: __('Neibu'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'weihu', title: __('Weihu'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'baodian', title: __('Baodian'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rated_speed_up', title: __('Rated_speed_up'), operate:'BETWEEN'},
                        {field: 'rated_speed_down', title: __('Rated_speed_down'), operate:'BETWEEN'},
                        {field: 'qudong', title: __('Qudong'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'rated_load_capacity', title: __('Rated_load_capacity')},
                        {field: 'sudu', title: __('Sudu'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'chicun', title: __('Chicun'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'lifting_height', title: __('Lifting_height'), operate:'BETWEEN'},
                        {field: 'floors', title: __('Floors'), operate: 'LIKE'},
                        {field: 'stations', title: __('Stations'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'doors', title: __('Doors'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'explosion_proof_type', title: __('Explosion_proof_type'), operate: 'LIKE'},
                        {field: 'dengji', title: __('Dengji'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'drive_motor_power', title: __('Drive_motor_power'), operate:'BETWEEN'},
                        {field: 'drive_motor_speed', title: __('Drive_motor_speed')},
                        {field: 'reduction_ratio', title: __('Reduction_ratio'), operate:'BETWEEN'},
                        {field: 'hydraulic_pump_station_pressure', title: __('Hydraulic_pump_station_pressure'), operate:'BETWEEN'},
                        {field: 'suspension_medium_type', title: __('Suspension_medium_type'), operate: 'LIKE'},
                        {field: 'suspension_medium_quantity', title: __('Suspension_medium_quantity')},
                        {field: 'suspension_medium_model', title: __('Suspension_medium_model'), operate: 'LIKE'},
                        {field: 'suspension_medium_specification', title: __('Suspension_medium_specification'), operate: 'LIKE'},
                        {field: 'code', title: __('Code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'code_img_url', title: __('Code_img_url'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'posttime', title: __('Posttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'checkinfo', title: __('Checkinfo'), searchList: {"true":__('True'),"false":__('False')}, formatter: Table.api.formatter.normal},
                        {field: 'input_clerk', title: __('Input_clerk'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'characteristic_number', title: __('Characteristic_number'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'manufacturing_unit', title: __('Manufacturing_unit'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'installation_unit', title: __('Installation_unit'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'usage_registration', title: __('Usage_registration'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'change_registration', title: __('Change_registration'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
